<?php

/**
 * Created by PhpStorm.
 * User: qian
 * Date: 2017/5/4
 * Time: 14:30
 */
class C_customerfeedback_detail
{
    private $resource;

    private $call_items;

    private $back_items;

    private $resource_id;

    public function __construct()
    {
        $this->resource = 'C_CustomerFeedback';

        $this->call_items = array(
            "t" => time(),
            "k" => "",
            'uid' => '',
            'v' => API_VERSION,
            "userType" => ""
        );

        $this->back_items = array(
            "feedback_list" => array(),
            "img_list"=> array(),
        );
    }

    public function set_call_items($obj = array())
    {
        foreach ($this->call_items as $key => $val) {
            if (isset($obj[$key])) {
                $this->call_items[$key] = $obj[$key];
            }
        }
        $this->set_resource_id($obj['refund_id']);
        $this->call_items['k'] = md5($obj['password'].$obj['refund_id'].$this->call_items['t']);
        return $this->_get_url();
    }

    public function set_back_items($data = array())
    {
        foreach ($this->back_items as $key => $val) {
            if (isset($data[$key])) {
                $this->back_items[$key] = $data[$key];
            }
        }
    }

    public function set_resource_id($id)
    {
        $this->resource_id = $id;
        return $this->_get_url();
    }

    public function get_call_items()
    {
        return $this->call_items;
    }

    public function get_back_items()
    {
        return $this->back_items;
    }

    public function get_resource_id()
    {
        return $this->resource_id;
    }

    private function _get_url()
    {
        if ($this->resource_id) {
            return $this->resource . '/' . $this->resource_id . '/';
        } else {
            return $this->resource . '/';
        }
    }
}